package com.LeeCode;

/**
 * 寻找峰值
 */

public class Code162 {
    public static void main(String[] args) {
        int[] nums = {1};
        System.out.println(new Code162().findPeakElement(nums));
    }

    public int findPeakElement(int[] nums) {
        int left = -1, right = nums.length - 1, n = nums.length - 1;
        while (left + 1 < right) {
            int mid = left + (right - left) / 2;
            if (mid == n || nums[mid] > nums[mid + 1]) {
                right = mid;
            } else {
                left = mid;
            }
        }
        return right;
    }
}
